/**
 * 应用配置管理
 * 注意：API Key相关功能已移至专用的apiKeyStore.ts文件
 */

// 配置键名常量
const AI_MODE_STORAGE_KEY = 'ai_mode'; // 'real' 或 'mock'

// 导入API Key管理函数
import { 
  getApiKey, 
  saveApiKey, 
  removeApiKey, 
  hasValidApiKey 
} from './apiKeyStore';

// 获取AI模式 ('real' 或 'mock')
export function getAiMode(): 'real' | 'mock' {
  try {
    const mode = localStorage.getItem(AI_MODE_STORAGE_KEY);
    return mode === 'real' ? 'real' : 'mock';
  } catch (error) {
    console.error('Failed to get AI mode from localStorage:', error);
    return 'mock';
  }
}

// 设置AI模式
export function setAiMode(mode: 'real' | 'mock'): void {
  try {
    localStorage.setItem(AI_MODE_STORAGE_KEY, mode);
  } catch (error) {
    console.error('Failed to set AI mode to localStorage:', error);
  }
}

// 重新导出API Key管理函数，保持向后兼容性
export { 
  getApiKey, 
  saveApiKey, 
  removeApiKey, 
  hasValidApiKey 
};